<?php

namespace App\Console\Commands;


use App\Models\Store;
use Illuminate\Console\Command;
use App\Services\Pay\GuoTonXinYi\Config;
use Illuminate\Support\Facades\Log;
use function EasyWeChat\Kernel\Support\get_client_ip;


class GtxyQueryCommand extends Command
{
    protected $signature = 'gtxy:query';
    protected $description = 'Export large datasets to CSV with memory optimization';

    public function handle()
    {
        $url = Config::getDomain() . Config::getReportInfo;
        $store_id = "20258693132128536";
        $store = Store::query()->where("store_id", $store_id)->first();
        list($mchNo, $config) = Config::config($store_id, "1234", "gtxy");
        dump($config);
        $reqData = [
            "agetId" => $config->platform_id,
            "custId" => $mchNo,
            "payWay" => "00",
            "timeStamp" => date("YmdHis", time()),
            "version" => Config::VERSION
        ];
        dump($reqData);
        $reqData["sign"] = Config::getSign($reqData, $config["public_key"]);
        $resultArray = Config::post($url, $reqData);
        Log::channel("gtxy")->info("orderQuery", [
            "reqData" => $reqData,
            "resData" => $resultArray
        ]);
        dd($resultArray);
    }
}